import i18n from '@/locales'
const reg =
  /^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/
let hostname = location.hostname
let domain
let ossEnv = 'dev'

if (hostname === 'localhost' || reg.test(hostname)) {
  domain = hostname
} else {
  hostname = hostname.split('.')
  let len = hostname.length

  domain = `.${hostname[len - 2]}.${hostname[len - 1]}`
}

window.domain = domain

var config = {
  projectName: i18n.t('南京临空跨境综合服务平台'),
  pageHeader: {
    screenful: true,
    theme: true,
    lang: true,
    message: true,
    height: 60,
  },
  historyMode: 'hash',
  axiosResponseType: 'json',
  customBg: [],
  customColor: [],
  home: '/personalCenter/dashbord',
  domain,
  tokenKey: 'contractTenantToken',
  isClient: false,
  ossEnv: ['production', 'prod'].includes(process.env.NODE_ENV)
    ? 'prod'
    : 'dev',
  ossBusiness: 'WH',
  ossModule: 'contract',
}

export default {
  development: Object.assign(
    {
      axiosBaseUrl: '/',
    },
    config
  ),
  production: Object.assign(
    {
      axiosBaseUrl: '',
    },
    config
  ),
}
